package com.lykj.llw.box.utils

import android.os.CountDownTimer
import androidx.fragment.app.FragmentManager
import com.lykj.llw.box.ui.diafrg.NetWorkDiaFrg

/**
 * ================================================
 * 描述
 * ================================================
 *
 * @author gosha
 * @date 2023/7/5-15:24
 */
object DialogUtils {
    private val mDialog = NetWorkDiaFrg()
    private var mCountDownTimer: CountDownTimer? = null


    fun show(manager: FragmentManager) {
        mDialog.show(manager, "网络弹窗")

        mCountDownTimer = object : CountDownTimer(7000, 1000) {
            override fun onTick(millisUntilFinished: Long) {
            }

            override fun onFinish() {
                dismiss()
            }
        }.start()
    }

    fun dismiss() {
        if (mDialog.isVisible) {
            mDialog?.dismissAllowingStateLoss()
            mCountDownTimer?.cancel()
        }
    }
}